<?php
/**
 * Created by PhpStorm.
 * User: liuxiu
 * Date: 2022/3/1
 * Time: 14:07
 */

namespace business\elasticsearch\repositories;


use business\elasticsearch\models\SubsBiddingModel;
use yii\elasticsearch\Query;

class SubBiddingRepository
{
    public function queryList($condition = [], $include = [], $from = 0, $size = 0, $highlight = [], $orderBy = [])
    {
        $query = (new Query())
            ->source($include)
            ->from(SubsBiddingModel::index(), SubsBiddingModel::type())
            ->query($condition);

        !empty($highlight) && $query->highlight($highlight);
        !empty($orderBy) && $query->orderBy($orderBy);

        $query->offset($from)->limit($size);

        return [
            $query->count(),
            $query->all()
        ];
    }
}